package com.nuoniu.sibanyun.service.production;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.nuoniu.sibanyun.entity.dto.ErpWorkProcedureCardDetailDto;
import com.nuoniu.sibanyun.entity.dto.WorkProcedureReportDto;
import com.nuoniu.sibanyun.entity.production.ErpWorkProcedureCardDetail;
import com.nuoniu.sibanyun.entity.production.ErpWorkProcedureCardMain;
import com.nuoniu.sibanyun.entity.vo.ErpWorkProcedureCardDetailVo;
import com.nuoniu.sibanyun.entity.vo.ProcedureCardDetailVo;
import com.nuoniu.sibanyun.entity.vo.WorkProcedureReportResult;

import java.util.List;

/**
 * <p>
 * 工序汇报 服务类
 * </p>
 *
 * @author 白强
 * @since 2021-03-30
 */
public interface IErpWorkProcedureCardDetailService extends IService<ErpWorkProcedureCardDetail> {


    /**
     * 新建 工序汇报
     * @param erpWorkProcedureCardDetail
     */
    void createCardDetail(ErpWorkProcedureCardDetail erpWorkProcedureCardDetail,String reportCode);

    /**
     * 批量上报 工序汇报 记录
     * @param erpWorkProcedureCardDetailList
     */
    void batchSaveCardDetail(List<ErpWorkProcedureCardDetail> erpWorkProcedureCardDetailList);

    /**
     * 批量提交条码 汇报工序
     * @param workProcedureReportDto
     */
    WorkProcedureReportResult batchSaveCardDetail(WorkProcedureReportDto workProcedureReportDto);

    /**
     * 通过IDs 查询 工序汇报记录
     * @param ids
     * @return
     */
    List<ProcedureCardDetailVo> listByIds(List<Long> ids);

    /**
     * 查询 工序汇报记录状态
     * @param ids
     * @return
     */
    List<ErpWorkProcedureCardDetail> getSimpleStatusByIds(List<Long> ids);
    /**
     * 批量审核
     * @param ids
     * @param status
     */
    void batchExamine(List<Long> ids,Integer status);

    /**
     * 批量删除
     * @param ids
     */
    void batchDelete(List<Long> ids);

    /**
     * 单个删除
     * @param id
     */
    void delete(Long id);

    /**
     * 获取 工序汇报单号
     * @param workProcedureDetailId         加工明细ID
     * @param productionWorkCode            加工单号
     * @return
     */
    String getReportCode(Integer workProcedureDetailId,String productionWorkCode);

    /**
     * 获取并设置 流水号 和 工序汇报单号
     * @param workProcedureDetailId     加工单明细
     * @param productionWorkCode        加工单编号
     */
    void getAndSetReportCode(ErpWorkProcedureCardDetail erpWorkProcedureCardDetail, Integer workProcedureDetailId,String productionWorkCode);


    /**
     * 查询 派工单ID 已经汇报的记录数量
     * @param productionDispatchId
     * @return
     */
    int sumByProductionDispatchId(Long productionDispatchId);

    /**
     * 通过 派工工序任务明细ID 查询工序汇报记录
     * @param workProcedureDetailId
     * @return
     */
    List<ProcedureCardDetailVo> listProcedureCardDetailVoMobile(Integer workProcedureDetailId);

    /**
     * 工序汇报生成 完工单
     * @param erpWorkProcedureCardDetail
     */
    void saveVProductionFinishMainFromCardDetail(ErpWorkProcedureCardDetail erpWorkProcedureCardDetail);

    /**
     * 分页查询 已经提交的 工序汇报
     * @return
     */
    Page<ErpWorkProcedureCardDetailVo> pageErpWorkProcedureCardDetailVo(Page page, ErpWorkProcedureCardDetailDto erpWorkProcedureCardDetailDto);


    /**
     * @title 校验 是否 工序汇报
     * @description
     * @author 白强
     * @updateTime 2021/12/25 15:48
     * @throws
     */
    boolean checkWorkReport(Long mainId);

    /**
     * @title 校验 是否 工序汇报
     * @description 
     * @author 白强 
     * @updateTime 2021/12/27 16:33 
     * @throws 
     */
    boolean checkWorkReportByWorkDetailIds(List<Long> workDetailIds);



    /***************************************** 2022 - 01 - 25 ************************************************/

    /**
     * 通过主表ID 删除明细
     * @param orderId
     */
    void deleteByOrderId(Long orderId);

    /**
     * 批量保存 工序明细
     * @param ErpWorkProcedureCardMain
     */
    void batchSaveDetails(ErpWorkProcedureCardMain ErpWorkProcedureCardMain);

    /**
     * 获取 简单 明细
     * @param orderId
     * @return
     */
    List<ErpWorkProcedureCardDetail> listQuantityVo(Long orderId);

    /**
     * 更新 加工单 工序明细 累计 汇报情况
     * @param beforeList
     * @param afterList
     */
    void updateProductionWorkProcedureCumQuantity(List<ErpWorkProcedureCardDetail> beforeList,List<ErpWorkProcedureCardDetail> afterList);


    /**
     * 计算工资
     * @param detailList
     */
    void calculateSalary(List<ErpWorkProcedureCardDetail> detailList);


}
